package com.mingrisoft.database;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.mingrisoft.R;

/**
 * Created by susu on 2024/4/19.
 */
public class grid5adapter  extends BaseAdapter {
    private deviceState [] devsts;
    private Context context;
    private LayoutInflater inflater;
    public grid5adapter(deviceState [] devsts, Context context) {
        super();
        this.devsts=devsts;
        this.context = context;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return devsts.length;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return devsts[position];
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View v, ViewGroup parent) {
        v = inflater.inflate(R.layout.iten5, null);
        TextView tv=  (TextView) v.findViewById(R.id.switchName);
        ImageView swIcon=(ImageView)v.findViewById(R.id.switchIcon);
        swIcon.setImageResource(devsts[position].getImageID());
        tv.setText(devsts[position].getDesc());
        return v;
    }
}
